<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>正方体</title>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
      section {
        width: 200px;
        height: 200px;
        margin: 100px auto;
        perspective: 10000px;
      }
      section:hover .box {
        transform: rotateX(360deg) rotateY(360deg);
      }
      .box {
        width: 200px;
        height: 200px;
        /* border: 1px solid black; */
        perspective: 10000px;
        /* 保留它内部3D效果 */
        transform-style: preserve-3d;
        position: relative;
        transition: all 10s ease 0s;
      }
      p {
        width: 200px;
        height: 200px;
        position: absolute;
      }
      .box p:nth-child(1) {
        background-color: rgba(255, 0, 234, 0.295);
        /* 前面 */
        transform: translateZ(100px);
      }
      .box p:nth-child(2) {
        background-color: rgba(255, 145, 0, 0.336);
        /* 顶面 */
        transform: rotateX(90deg) translateZ(100px);
      }
      .box p:nth-child(3) {
        background-color: rgba(179, 255, 0, 0.384);
        /* 背面 */
        transform: rotateX(180deg) translateZ(100px);
      }

      .box p:nth-child(4) {
        background-color: rgba(0, 26, 255, 0.37);
        /* 底面 */
        transform: rotateX(-90deg) translateZ(100px);
      }
      .box p:nth-child(5) {
        background-color: rgba(0, 255, 128, 0.485);
        /* 侧面 */
        transform: rotateY(90deg) translateZ(100px);
      }
      .box p:nth-child(6) {
        background-color: rgba(255, 0, 106, 0.39);
        /* 侧面 */
        transform: rotateY(-90deg) translateZ(100px);
      }
    </style>
  </head>
  <body>
    <section>
      <div class="box">
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
      </div>
    </section>
  </body>
</html>
